<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Axios restful</title>
  </head>
  <body>
    <script src="./js/axios.js"></script>
    <script>
      //1. get的传统方式传参数
      axios.get("http://localhost:3000/axios?id=999").then(function (response) {
        console.log(response.data);
      });
      //2. restful的传统方式传参数
      axios.get("http://localhost:3000/axios/888").then(function (response) {
        console.log(response.data);
      });

      //属于传统的传参方式
      axios
        .get("http://localhost:3000/axios", {
          params: { id: 777 },
        })
        .then(function (response) {
          console.log(response.data);
        });

      axios.delete("http://localhost:3000/books/666").then(function (response) {
        console.log(response.data);
      });

      axios
        .post("http://localhost:3000/books", {
          uname: "python",
          pwd: "333",
        })
        .then(function (response) {
          console.log(response.data);
        });

        axios
        .put("http://localhost:3000/books/222", {
          uname: "C++",
          pwd: "555",
        })
        .then(function (response) {
          console.log(response.data);
        });
    </script>
  </body>
</html>
